package cn.yunlang.zhangZhongFei.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import cn.yunlang.zhangZhongFei.entity.AwardMessage;
import cn.yunlang.zhangZhongFei.service.AwardMessageService;
import cn.yunlang.zhangZhongFei.vo.response.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/AwardMessage")
@Api(tags = "抽奖消息记录")
public class AwardMessageController {

  @Resource private AwardMessageService awardMessageService;

  //    @ApiOperation("全查")
  //    @GetMapping("/list")
  //    public R<List<AwardMessage>> list() {
  //        return R.success(awardMessageService.list());
  //    }

  @ApiOperation("分页查")
  @GetMapping("/page")
  public R<IPage<AwardMessage>> page(
      @ApiParam(value = "页码", required = true) @RequestParam Integer pageNo,
      @ApiParam(value = "每页大小", required = true) @RequestParam Integer pageSize,
      @ApiParam(value = "消息内容", required = false) @RequestParam(required = false) String message) {
    return awardMessageService.pageAwardMessages(pageNo, pageSize, message);
  }

  //    @GetMapping("/one")
  //    @ApiOperation("根据Id查一条")
  //    public R<AwardMessage> one(@RequestParam Long awardMessageId) {
  //        AwardMessage awardMessage = awardMessageService.getById(awardMessageId);
  //        return R.success(awardMessage);
  //    }
  //
  //    @PostMapping("/add")
  //    @ApiOperation("新增")
  //    public R<String> add(@RequestBody AwardMessage awardMessage) {
  //        boolean save = awardMessageService.save(awardMessage);
  //        if (save){
  //            return R.success("新增成功");
  //        }
  //        return R.error(500,"新增失败");
  //    }
  //
  //    @GetMapping("/delete")
  //    @ApiOperation("删除")
  //    public R<String> delete(@RequestParam Long awardMessageId) {
  //        boolean remove = awardMessageService.removeById(awardMessageId);
  //        if (remove){
  //            return R.success("删除成功");
  //        }
  //        return R.error(500,"删除失败");
  //    }
  //
  //    @PostMapping("/update")
  //    @ApiOperation("修改")
  //    public R<String> update(@RequestBody AwardMessage awardMessage) {
  //        boolean update = awardMessageService.updateById(awardMessage);
  //            if (update){
  //            return R.success("修改成功");
  //        }
  //        return R.error(500,"修改失败");
  //    }

}
